package com.songlanyun.modules.exception;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.songlanyun.common.drive.IntegerEnum;

import java.util.Objects;

public enum SearchException implements IntegerEnum<Integer> {

    KEY_WORD_NOT_NULL(80001, "关键词不能为空"),
    KEY_WORD_TOO_LONG(80002, "关键词不能超过50个字"),
            ;


    private Integer code;

    private String msg;

    SearchException(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }
    @Override
    public Integer getCode() {
        return code;
    }

    @Override
    public String getMsg() {
        return msg;
    }


    @JsonCreator
    public static SearchException getByCode(int code) {
        for (SearchException value : SearchException.values()) {
            if (Objects.equals(code, value.getCode())) {
                return value;
            }
        }
        return null;
    }
}
